package com.sugon.dao;

import com.sugon.entity.SpareStorePosEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 备件仓库位置关联 用于存储备件位置以及数量Dao
 *
 * @author sugon
 * @date 2020-03-09 11:31:06
 */
public interface SpareStorePosDao extends BaseDao<SpareStorePosEntity> {

    /**
     * 获取指定备件数库存汇总数
     *
     * @param sparePartId
     * @return
     */
    Integer sumStockNum(@Param("sparePartId") String sparePartId);

    /**
     * 查询某个仓库下的备件ID列表
     *
     * @param storeHouseId 仓库ID
     * @return
     */
    @Select("select distinct SPARE_CODE from SPARE_STORE_POS where STORE_ID = #{storeHouseId}")
    List<String> queryStoreHouseSpare(@Param("storeHouseId") String storeHouseId);

    /**
     * 删除指定仓库下的所有库位，逻辑删除
     *
     * @param storeHouseId 仓库ID
     * @return
     */
    @Delete("UPDATE SPARE_STORE_POS SET DEL_FLAG = 0 where STORE_ID = #{storeHouseId}")
    int deleteByStoreId(@Param("storeHouseId") String storeHouseId);

}
